<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\service\kuaishou;

use app\enum\KsCodeEnum;
use app\enum\KuaiShouUrlEnum;
use app\service\BaseService;
use proxy\Client;

final class DspService extends BaseService
{
    public static function picShare(array $headers = [], array $params = [])
    {
        try {
            $client = new Client();
            $serviceName = KuaiShouUrlEnum::getServiceName('dsp');
            $serviceUrl = KuaiShouUrlEnum::getServiceUrl('dsp', 'pic_share');

            $res = $client->postJson($serviceName, $serviceUrl, $params)->setHeader($headers)->exec(Client::RETURN_TYPE);
            dump($res);
            if (intval($res['code']) != KsCodeEnum::SUCCESS) {
                return self::setError($res['message']);
            }

            return $res;
        } catch (\Exception $e) {
            dump($e->getMessage());
            return self::setError($e->getMessage());
        }
    }
}
